<template>
  <div class="">
    <ul>
      <li
        v-for="i in 10"
        :key="i"
        @click="change(i)"
        :class="i == flag ? bg : ''"
      >
        {{ i }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: "",
      bg: "active",
    };
  },
  mounted() {},
  methods: {
    change(i) {
      this.flag = i;
      if (i % 2 == 0) {
        this.bg = "active";
      } else {
        this.bg = "active1";
      }
    },
  },
};
</script>

<style lang="scss">
li.active {
  background: pink;
}
li.active1 {
  background: blue;
}
</style>
